package com.example.leetdemo.finash;

public class Solution1716 {

    public int totalMoney(int n) {
        int p = n / 7, q = n % 7;
        int result = p * 28;
        for (int i = 1; i < p; i++) {
            result += 7 * i;
        }
        for (int i = 0; i < q; i++) {
            result += p + 1 + i;
        }
        return result;
    }

    public static void main(String[] args) {
        Solution1716 solution1716 = new Solution1716();
        System.err.println(solution1716.totalMoney(10));
    }

}
